﻿using System.Windows;
using System.Collections.Generic;
using FireFly;
using System.Collections;

namespace XAMLStylePad.ViewModels.TriggersAndSetters
{
    public class TriggerViewModel : TriggerViewModelBase<Trigger>
    {
        public TriggerViewModel(Trigger trigger)
            : base(trigger)
        {

        }

        #region Property
        public DependencyProperty Property
        {
            get
            {
                return Model.Property;
            }
            set
            {
                Model.Property = value;
                OnPropertyChanged("Property");
            }
        }
        #endregion

        #region Value
        public object Value
        {
            get
            {
                return Model.Value;
            }
            set
            {
                Model.Value = value;
                OnPropertyChanged("Value");
            }
        }
        #endregion

        #region SourceName
        public string SourceName
        {
            get
            {
                return Model.SourceName;
            }
            set
            {
                Model.SourceName = value;
                OnPropertyChanged("SourceName");
            }
        }
        #endregion

        #region Setters
        public SetterCollectionViewModel Setters
        {
            get
            {
                if(_Setters == null)
                {
                    _Setters = new SetterCollectionViewModel(Model.Setters)
                    {
                        Parent = this,
                        DisplayName = "Setters"
                    };
                }
                return _Setters;
            }
        }
        SetterCollectionViewModel _Setters;
        #endregion

        public override string DisplayName
        {
            get
            {
                return string.Format("{0} == {1}", Property, Value);
            }
        }

        public override ICollection VisualChildren
        {
            get
            {
                return ViewModelService.Instance.CombineVisualChildren(EnterActions, ExitActions, Setters);
            }
        }
    }
}